from fastapi import Query
from pydantic import BaseModel
from typing import Optional
from like.common.enums import LoginTypeEnum, LoginClientEnum


class FrontLoginCheckOut(BaseModel):
    """
    登录管理 返回信息
    """
    id: int
    token: str
    isBindMobile: bool


class FrontRegisterIn(BaseModel):
    """
    注册 入参
    """
    username: str = Query(min_length=3, max_length=12, regex='^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{3,12}$')
    # password: str = Query(min_length=6, max_length=12)
    # client: LoginClientEnum
    # username: Optional[str] = Query(
    #     None,  # 设置为 None 表示该字段可选
    #     min_length=3,
    #     max_length=12,
    #     regex='^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{3,12}$',
    #     description="用户名，3-12 位，必须包含字母和数字"
    # )
    password: Optional[str] = Query(
        None,  # 设置为 None 表示该字段可选
        min_length=6,
        max_length=12,
        description="密码，6-12 位"
    )
    client: Optional[LoginClientEnum] = Query(
        None, 
        description="客户端类型"
    )
    # account: Optional[str] = Query(
    #     None, 
    #     description="账号，可选字段"
    # )
    password_confirm: Optional[str] = Query(
        None, 
        description="确认密码，可选字段"
    )

class FrontLoginCheckIn(BaseModel):
    """
    手机端-登录管理 入参
    """
    scene: LoginTypeEnum # 登录方式
    terminal: LoginClientEnum  # 登录端
    username: str = Query(default=None)
    password: str = Query(default=None)
    # mobile: str = Query(default=None)
    # code: str = Query(default=None)
    mobile: Optional[str] = Query(default=None)    # 将 mobile 设置为可选项
    code: Optional[str] = Query(default=None)      # 将 code 设置为可选项